package com.example.todoappserver.controller;

import com.example.todoappserver.service.ITodoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class TodoController {

    @Autowired
    ITodoService service;

    @ResponseBody
    @RequestMapping("/getTodoList")
    public HashMap<String,Object>  getTodoList(){
        HashMap<String,Object> result = new HashMap();
        result.put("todoListData",service.getTodoList());
        return result;
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.POST,value = "/addTodo")
    public Map addTodo(HttpServletRequest request){
        return service.addTodo(request);
    }

    @ResponseBody
    @RequestMapping("/updateTodo")
    public Map updateTodo(HttpServletRequest request){
        return service.updateTodo(request);
    }
}
